package com.um.jdy.app.user.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.um.jdy.app.user.entity.dto.WalletListQuery;
import com.um.jdy.app.user.entity.dto.WalletRechargeParam;
import com.um.jdy.app.user.entity.vo.DepositCashoutVO;
import com.um.jdy.app.user.entity.vo.UserBillListVO;
import com.um.jdy.app.user.entity.vo.WalletDetailVO;
import com.um.jdy.app.user.entity.vo.WalletListVO;
import com.um.jdy.app.user.manager.AddressManager;
import com.um.jdy.app.user.manager.WalletManager;
import com.um.jdy.common.member.entity.dto.AddressDTO;
import com.um.jdy.common.member.entity.vo.AddressVO;
import com.um.jdy.common.member.entity.vo.RechargePackageVO;
import com.um.springboot.starter.annotation.ActionLogRequired;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.entity.Response;
import com.um.springboot.starter.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.Set;


@SaCheckLogin
@Api(tags = "收货地址")
@RestController
@RequestMapping("/api/v1/user/address")
public class AddressController {

    @Autowired
    AddressManager addressManager;

    @ApiOperation("查询所有收货地址")
    @GetMapping()
    public Response<List<AddressVO>> getList(){
        return Response.success(addressManager.getList());
    }

    @ApiOperation("查询收货地址，id为null时返回默认收货地址")
    @GetMapping("{id}")
    public Response<AddressVO> get(@ApiParam("收货地址ID") @PathVariable String id){
        return Response.success(addressManager.get(id));
    }

    @ApiOperation("新增收货地址")
    @PostMapping()
    public Response create(@RequestBody AddressDTO dto){
        addressManager.add(dto);
        return Response.success();
    }

    @ApiOperation("编辑收货地址")
    @PutMapping("{id}")
    public Response update(@ApiParam("收货地址ID") @PathVariable String id, @RequestBody AddressDTO dto){
        addressManager.update(id, dto);
        return Response.success();
    }

    @ApiOperation("删除收货地址")
    @DeleteMapping("{id}")
    public Response delete(@ApiParam("收货地址ID") @PathVariable String id){
        addressManager.delete(id);
        return Response.success();
    }


}
